package com.ruoyi.teaching.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.teaching.domain.PlatformCCourseOutline;
import com.ruoyi.teaching.mapper.PlatformCCourseOutlineMapper;
import com.ruoyi.teaching.service.PlatformCCourseOutlineService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 王旭
 * @since 2024-06-24
 */
@Service
public class PlatformCCourseOutlineServiceImpl extends ServiceImpl<PlatformCCourseOutlineMapper, PlatformCCourseOutline> implements PlatformCCourseOutlineService {

    @Autowired
    private PlatformCCourseOutlineMapper platformCCourseOutlineMapper;

    @Override
    public AjaxResult selectPlatformCCourseOutlineListTeacher(Integer parentId, Integer courseId) {
        int userId = SecurityUtils.getUserId().intValue();
        QueryWrapper<PlatformCCourseOutline> platformCCourseOutlineQueryWrapper = new QueryWrapper<>();
        if(parentId != null){
            platformCCourseOutlineQueryWrapper.eq("parent_id", parentId);
        }
        if(courseId != null){
            platformCCourseOutlineQueryWrapper.eq("course_id", courseId);
        }
        platformCCourseOutlineQueryWrapper.eq("create_id",userId);
        List<PlatformCCourseOutline> platformCCourseOutlines = platformCCourseOutlineMapper.selectList(platformCCourseOutlineQueryWrapper);
        return new AjaxResult(HttpStatus.SUCCESS,"查询成功",platformCCourseOutlines);
    }
}
